package com.entites;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.NamedStoredProcedureQueries;
import javax.persistence.NamedStoredProcedureQuery;
import javax.persistence.OneToMany;
import javax.persistence.ParameterMode;
import javax.persistence.StoredProcedureParameter;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

@Entity
@Table(name = "EventLibrary")
@XmlRootElement
@NamedQueries(
        {
            @NamedQuery(name = "EventLibrary.findAll", query = "SELECT e FROM EventLibrary e"),
            @NamedQuery(name = "EventLibrary.findByEventId", query = "SELECT e FROM EventLibrary e WHERE e.eventId = :eventId"),
            @NamedQuery(name = "EventLibrary.findByName", query = "SELECT e FROM EventLibrary e WHERE e.name = :name"),
            @NamedQuery(name = "EventLibrary.findByDescription", query = "SELECT e FROM EventLibrary e WHERE e.description = :description"),
            @NamedQuery(name = "EventLibrary.findByEventType", query = "SELECT e FROM EventLibrary e WHERE e.eventType = :eventType"),
            @NamedQuery(name = "EventLibrary.findByTimeStart", query = "SELECT e FROM EventLibrary e WHERE e.timeStart = :timeStart"),
            @NamedQuery(name = "EventLibrary.findByTimeEnd", query = "SELECT e FROM EventLibrary e WHERE e.timeEnd = :timeEnd")
        })
@NamedStoredProcedureQueries({
    @NamedStoredProcedureQuery(name = "EventLibrary.findAllEveventLibraryOrderByDesc", procedureName = "sp_getEventLibraryPaging", parameters = {
        @StoredProcedureParameter(name = "beginRow", mode = ParameterMode.IN, type = Integer.class),
        @StoredProcedureParameter(name = "endRow", mode = ParameterMode.IN, type = Integer.class),
        @StoredProcedureParameter(name = "Username", mode = ParameterMode.IN, type = String.class)
    }),
    @NamedStoredProcedureQuery(name = "EventLibrary.getEventDetailsById", procedureName = "sp_getEventDetailsById", parameters = {
        @StoredProcedureParameter(name = "eventId", mode = ParameterMode.IN, type = Integer.class),
        @StoredProcedureParameter(name = "username", mode = ParameterMode.IN, type = String.class),}),
    @NamedStoredProcedureQuery(name = "EventLibrary.getListEventLibraryRelated", procedureName = "sp_getListEventLibraryRelated", parameters = {
        @StoredProcedureParameter(name = "eventType", mode = ParameterMode.IN, type = String.class),}),
    @NamedStoredProcedureQuery(name = "EventLibrary.SearchEventLibrary", procedureName = "sp_SearchEventLibrary", parameters = {
        @StoredProcedureParameter(name = "beginRow", mode = ParameterMode.IN, type = Integer.class),
        @StoredProcedureParameter(name = "endRow", mode = ParameterMode.IN, type = Integer.class),
        @StoredProcedureParameter(name = "username", mode = ParameterMode.IN, type = String.class),
        @StoredProcedureParameter(name = "parameter", mode = ParameterMode.IN, type = String.class)
    }),
    @NamedStoredProcedureQuery(name = "EventLibrary.getCountRecordSearch", procedureName = "sp_getCountRecordSearch", parameters = {
        @StoredProcedureParameter(name = "parameter", mode = ParameterMode.IN, type = String.class)
    }),
    @NamedStoredProcedureQuery(name = "EventLibrary.getEventUpcoming", procedureName = "sp_getUpcomingEvent", parameters = {
        @StoredProcedureParameter(name = "Username", mode = ParameterMode.IN, type = String.class)
    }),
   
})
public class EventLibrary implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "EventId")
    private Integer eventId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "Name")
    private String name;
    @Size(max = 1073741823)
    @Column(name = "Description")
    private String description;
    @Size(max = 100)
    @Column(name = "EventType")
    private String eventType;
    @Basic(optional = false)
    @NotNull
    @Column(name = "TimeStart")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeStart;
    @Basic(optional = false)
    @NotNull
    @Column(name = "TimeEnd")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeEnd;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "eventId")
    private List<EventComment> eventCommentList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "eventId")
    private List<EventGift> eventGiftList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "eventId")
    private List<EventRegistration> eventRegistrationList;
    private String status;
    private String type;
    private int commnetCount;
    private int joinedCount;
    private String image;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date timeCreate;

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public Date getTimeCreate() {
        return timeCreate;
    }

    public void setTimeCreate(Date timeCreate) {
        this.timeCreate = timeCreate;
    }

    public int getJoinedCount() {
        return joinedCount;
    }

    public void setJoinedCount(int joinedCount) {
        this.joinedCount = joinedCount;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public int getCommnetCount() {
        return commnetCount;
    }

    public void setCommnetCount(int commnetCount) {
        this.commnetCount = commnetCount;
    }

    public EventLibrary() {
    }

    public EventLibrary(Integer eventId) {
        this.eventId = eventId;
    }

    public EventLibrary(Integer eventId, String name, String description, String eventType, Date timeStart, Date timeEnd) {
        this.eventId = eventId;
        this.name = name;
        this.description = description;
        this.eventType = eventType;
        this.timeStart = timeStart;
        this.timeEnd = timeEnd;
    }

    public EventLibrary(Integer eventId, String name, String description, String eventType, Date timeStart, Date timeEnd, String status, String type) {
        this.eventId = eventId;
        this.name = name;
        this.description = description;
        this.eventType = eventType;
        this.timeStart = timeStart;
        this.timeEnd = timeEnd;
        this.status = status;
        this.type = type;
    }

    public EventLibrary(Integer eventId, String name, String description, String eventType, Date timeStart, Date timeEnd, String image, Date timeCreate, String status, String type, int commentCount, int joinedCount) {
        this.eventId = eventId;
        this.name = name;
        this.description = description;
        this.eventType = eventType;
        this.timeStart = timeStart;
        this.timeEnd = timeEnd;
        this.image = image;
        this.timeCreate = timeCreate;
        this.status = status;
        this.type = type;
        this.commnetCount = commentCount;
        this.joinedCount = joinedCount;
    }

    public Integer getEventId() {
        return eventId;
    }

    public void setEventId(Integer eventId) {
        this.eventId = eventId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getEventType() {
        return eventType;
    }

    public void setEventType(String eventType) {
        this.eventType = eventType;
    }

    public Date getTimeStart() {
        return timeStart;
    }

    public void setTimeStart(Date timeStart) {
        this.timeStart = timeStart;
    }

    public Date getTimeEnd() {
        return timeEnd;
    }

    public void setTimeEnd(Date timeEnd) {
        this.timeEnd = timeEnd;
    }

    @XmlTransient
    public List<EventComment> getEventCommentList() {
        return eventCommentList;
    }

    public void setEventCommentList(List<EventComment> eventCommentList) {
        this.eventCommentList = eventCommentList;
    }

    @XmlTransient
    public List<EventGift> getEventGiftList() {
        return eventGiftList;
    }

    public void setEventGiftList(List<EventGift> eventGiftList) {
        this.eventGiftList = eventGiftList;
    }

    @XmlTransient
    public List<EventRegistration> getEventRegistrationList() {
        return eventRegistrationList;
    }

    public void setEventRegistrationList(List<EventRegistration> eventRegistrationList) {
        this.eventRegistrationList = eventRegistrationList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (eventId != null ? eventId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EventLibrary)) {
            return false;
        }
        EventLibrary other = (EventLibrary) object;
        if ((this.eventId == null && other.eventId != null) || (this.eventId != null && !this.eventId.equals(other.eventId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entites.EventLibrary[ eventId=" + eventId + " ]";
    }

}
